package com.dawn.module.hospital.dal.mysql.invoice;

import java.util.*;

import com.dawn.framework.common.pojo.PageResult;
import com.dawn.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.dawn.framework.mybatis.core.mapper.BaseMapperX;
import com.dawn.module.hospital.dal.dataobject.invoice.InvoiceDO;
import org.apache.ibatis.annotations.Mapper;
import com.dawn.module.hospital.controller.admin.invoice.vo.*;

/**
 * 发票 Mapper
 *
 * @author root
 */
@Mapper
public interface InvoiceMapper extends BaseMapperX<InvoiceDO> {

    default PageResult<InvoiceDO> selectPage(InvoicePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<InvoiceDO>()
                .eqIfPresent(InvoiceDO::getUserId, reqVO.getUserId())
                .eqIfPresent(InvoiceDO::getOpenid, reqVO.getOpenid())
                .likeIfPresent(InvoiceDO::getOrgName, reqVO.getOrgName())
                .eqIfPresent(InvoiceDO::getOrgCode, reqVO.getOrgCode())
                .likeIfPresent(InvoiceDO::getPatientName, reqVO.getPatientName())
                .eqIfPresent(InvoiceDO::getIdCardNo, reqVO.getIdCardNo())
                .eqIfPresent(InvoiceDO::getPatientId, reqVO.getPatientId())
                .eqIfPresent(InvoiceDO::getClinicNo, reqVO.getClinicNo())
                .eqIfPresent(InvoiceDO::getOrderNumber, reqVO.getOrderNumber())
                .eqIfPresent(InvoiceDO::getOrderType, reqVO.getOrderType())
                .likeIfPresent(InvoiceDO::getOrderName, reqVO.getOrderName())
                .eqIfPresent(InvoiceDO::getAmout, reqVO.getAmout())
                .eqIfPresent(InvoiceDO::getOperator, reqVO.getOperator())
                .eqIfPresent(InvoiceDO::getOperateType, reqVO.getOperateType())
                .eqIfPresent(InvoiceDO::getSettleId, reqVO.getSettleId())
                .eqIfPresent(InvoiceDO::getInvoiceType, reqVO.getInvoiceType())
                .eqIfPresent(InvoiceDO::getInvoiceNo, reqVO.getInvoiceNo())
                .eqIfPresent(InvoiceDO::getInvoiceCode, reqVO.getInvoiceCode())
                .eqIfPresent(InvoiceDO::getInvoiceUrl, reqVO.getInvoiceUrl())
                .eqIfPresent(InvoiceDO::getCheckCode, reqVO.getCheckCode())
                .eqIfPresent(InvoiceDO::getRemark, reqVO.getRemark())
                .eqIfPresent(InvoiceDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(InvoiceDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(InvoiceDO::getId));
    }

}